import { FormProps, FormSchema } from '@/components/Table'
import { BasicColumn } from '@/components/Table/src/types/table'

// 命名空间列表
export function getApplicationBasicColumns(): BasicColumn[] {
  return [
    {
      title: '应用名称',
      width: 140,
      customEllipsis: true,
      dataIndex: 'appName'
    },
    {
      title: '应用地址',
      width: 180,
      customEllipsis: true,
      dataIndex: 'requestUrl'
    },
    {
      title: '应用描述',
      width: 140,
      customEllipsis: true,
      dataIndex: 'appDescribe'
    },
    {
      title: '平台侧',
      width: 80,
      dataIndex: 'appPlatform'
    },
    {
      title: '应用状态',
      width: 80,
      dataIndex: 'appStatus'
    },
    {
      title: '创建时间',
      width: 140,
      dataIndex: 'createDate'
    },
    {
      title: '操作',
      width: 120,
      dataIndex: 'operate'
    }
  ]
}

export function getSearchFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 80,
    baseColProps: {
      span: 6,
      md: 8,
      xl: 8,
      xxl: 6
    },
    schemas: [
      {
        field: 'appName',
        label: '应用名称',
        component: 'Input'
      }
    ]
  }
}

export function getApplicationFormConfig(): Partial<FormProps> {
  return {
    layout: 'vertical',
    showActionButtonGroup: false,
    baseColProps: {
      span: 24,
      style: {
        marginBottom: '4px'
      }
    },
    schemas: [
      {
        field: 'appStatus',
        component: 'Switch',
        label: '应用状态',
        defaultValue: '0',
        componentProps: {
          checkedChildren: '正常',
          unCheckedChildren: '禁用',
          checkedValue: '0',
          unCheckedValue: '1'
        }
      },
      {
        field: 'appName',
        component: 'Input',
        label: '应用名称',
        required: true
      },
      {
        field: 'appPlatform',
        component: 'Select',
        label: '平台侧',
        rules: [{ required: true, trigger: 'change' }],
        defaultValue: '1',
        componentProps: {
          options: [
            {
              label: '否',
              value: '0',
              key: '0'
            },
            {
              label: '是',
              value: '1',
              key: '1'
            }
          ]
        }
      },
      {
        field: 'requestUrl',
        component: 'Input',
        label: '应用请求地址'
      },
      {
        field: 'appDescribe',
        component: 'InputTextArea',
        label: '应用描述',
        componentProps: {
          autoSize: { minRows: 3, maxRows: 3 }
        }
      }
    ]
  }
}
